/* POJ 1008 */
#include <stdio.h>
#include <string.h>

const char Haab[19][8] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax",
                       "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"};
const char Tzolkin[20][12] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok",
                   "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};

int main(int argc, char const *argv[])
{
    int n;
    scanf("%d", &n);
    printf("%d\n", n);

    int Hyear, Hmon, Hday;
    int Tyear, Tmon, Tday;
    int days;
    char buf[8];
    while (n--) {
        scanf("%d.%s%d", &Hday, buf, &Hyear);
        for (int i = 0; i < 19; i++) {
            if (strcmp(buf, Haab[i]) == 0) {
                Hmon = i;
                break;
            }
        }
        days = Hyear * 365 + Hmon * 20 + Hday;

        Tyear = days / 260;
        days %= 260;
        Tmon = days % 20;
        Tday = days % 13 + 1;
        printf("%d %s %d\n", Tday, Tzolkin[Tmon], Tyear);
    }

    return 0;
}
